package com.score.student.service.Impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.score.student.domain.dto.ExamAddDTO;
import com.score.student.domain.po.Exam;
import com.score.student.domain.vo.AllExamVO;
import com.score.student.mapper.ExamMapper;
import com.score.student.service.IExamService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author
 * @version 1.0
 */
@Service
public class IExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IExamService {


    @Override
    public void add(ExamAddDTO examAddDTO) {
        Exam exam = BeanUtil.copyProperties(examAddDTO, Exam.class);
        exam.setCreateTime(LocalDateTime.now());
        this.save(exam);
    }

    @Override
    public AllExamVO allExam() {
        return new AllExamVO(lambdaQuery().list());
    }

    @Override
    public Exam queryNameById(Integer id) {

        return lambdaQuery()
                .eq(Exam::getId, id)
                .one();


    }
}
